package com.eee.machine.dao.mapper;

import com.eee.machine.beans.TChannelProduct;
import com.eee.machine.beans.TChannelProductExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;

public interface TChannelProductMapper {
    long countByExample(TChannelProductExample example);

    int deleteByExample(TChannelProductExample example);

    int deleteByPrimaryKey(String tChannelProductId);

    int insert(TChannelProduct record);

    int insertSelective(TChannelProduct record);

    List<TChannelProduct> selectByExample(TChannelProductExample example);

    TChannelProduct selectByPrimaryKey(String tChannelProductId);

    int updateByExampleSelective(@Param("record") TChannelProduct record, @Param("example") TChannelProductExample example);

    int updateByExample(@Param("record") TChannelProduct record, @Param("example") TChannelProductExample example);

    int updateByPrimaryKeySelective(TChannelProduct record);

    int updateByPrimaryKey(TChannelProduct record);

    @Select("SELECT * FROM `t_channel_product` WHERE t_machine_id = #{machineId} AND t_product_id = #{productId}")
    @ResultMap(value = "com.eee.machine.dao.mapper.TChannelProductMapper.BaseResultMap")
    List<TChannelProduct> getSurplusProduct(@Param("machineId") String machineId, @Param("productId") String productId);

    @Update("UPDATE `t_channel_product` SET product_num = #{num} WHERE t_channel_id = #{lineSort}")
    int decreaseProduct(@Param("num") int num, @Param("lineSort") String lineSort);

    @Select("SELECT * FROM `t_channel_product` WHERE t_channel_id = #{lingSort} and t_product_id = #{itemId}")
    List<TChannelProduct>  getHasDeliverGood(@Param("lingSort") String lingSort, @Param("itemId") String itemId);

    @Select("SELECT * FROM `t_channel_product` WHERE t_product_id = #{itemId} and t_machine_id = #{machineId}")
    @ResultMap(value = "com.eee.machine.dao.mapper.TChannelProductMapper.BaseResultMap")
    TChannelProduct checkGood(@Param("itemId") String itemId, @Param("machineId") String machineId);

}